    <?php
    $Server = "localhost";
$Username = "root";
$Password = "";
$Database = "db_cuti";


		mysql_connect($Server,$Username,$Password) or die("Koneksi gagal");
		mysql_select_db($Database) or die("Database tidak bisa dibuka");

// Mengambil id_surat yang akan dilihat
					$IdSurat = $_GET['IdSurat'];

					// Mengambil data surat 
					$Surat = mysql_query("SELECT * FROM d_surat WHERE id_surat = '$IdSurat'");
					$Data1 = mysql_fetch_array($Surat);

					// Mengambil data karyawan
					$Karyawan = mysql_query("SELECT * FROM d_karyawan WHERE id_karyawan = '$Data1[id_karyawan]'");
					$Data2 = mysql_fetch_array($Karyawan);

					// Data yang akan ditampilkan dari tabel karyawan
					$NamaLengkap = $Data2['nama_lengkap'];
					$tlc = $Data2['tlc'];
					$Jabatan = $Data2['jabatan'];
					$UnitKerja = $Data2['unit_kerja'];

					// Data yang akan ditampilkan dari tabel surat
					$Tgl_Pengajuan = $Data1['tgl_pengajuan'];
					
					$Jumlah_Cuti = $Data1['jumlah_cuti'];
					$JenisSurat = $Data1['jenis_surat'];
					// Mengubah jenis surat
					include("config/jenis_surat.php");
					$Keperluan = $Data1['keperluan'];
					$Atasan = $Data1['id_atasan'];
					if ($Atasan != "-" OR $Atasan != "")
					{
					// Mengambil tlc approval
					$IdAtasan = mysql_query("SELECT * FROM d_karyawan WHERE id_karyawan = '$Atasan'");
					$Data4 = mysql_fetch_array($IdAtasan);
					$Atasan = $Data4['tlc'];
					}
					
					$KetApproval = $Data1['ket_approval'];
					// Mengubah ket approval
					include("config/ket_approval.php");
					$Approval = $Data1['id_approval'];
					if ($Approval != "-" OR $Approval != "")
					{
					// Mengambil tlc approval
					$IdAproval = mysql_query("SELECT * FROM d_karyawan WHERE id_karyawan = '$Approval'");
					$Data3 = mysql_fetch_array($IdAproval);
					$Approval = $Data3['tlc'];
					}
					$TglKet = $Data1['tgl_ket_approval'];	
					
					// Memecah tanggal string ke array
						
						
						$KetTgl = (str_replace('-',' , ',$Data1['ket_tgl_cuti']));
				
	
    $pdf=new HTML2FPDF();
    $pdf->AddPage();
    $strContent = 
	"
	<h1><p align='center'>LAPORAN PENGAJUAN CUTI</p></h1>
	<table border=2 cellpadding=10 width='700' >					
					<tr>
					<td colspan=4 align='center'  height='70'  ><h1>Surat Cuti</h1></td>
					</tr>					
						<tr>
						<td height='30'>Nama :</td>
						<td >$NamaLengkap</td>
						<td >Jabatan :</td>
						<td >$Jabatan</td>
						</tr>						
						<tr>
						<td height='30'>Tlc :</td>
						<td>$tlc</td>
						<td>Unit Kerja :</td>
						<td>$UnitKerja</td>
						</tr>					
					<tr>
					<td colspan=4 align='center' height='70'  ><h4>Data Surat</h4></td>
					</tr>					
						<tr>
						<td colspan=2 height='30'>Tanggal Mengajukan :</td>
						<td colspan=2>$Tgl_Pengajuan</td>
						</tr>						
						<tr>
						<td colspan=2 height='30'>Keterangan Tanggal :</td>
						<td colspan=2>$KetTgl 
						
						</td>
						</tr>						
						<tr>
						<td colspan=2 height='30'>Jumlah Cuti :</td>
						<td colspan=2>$Jumlah_Cuti</td>
						</tr>						
						<tr>
						<td colspan=2 height='30'>Jenis Surat :</td>
						<td colspan=2>$JenisSurat</td>
						</tr>						
						<tr>
						<td colspan=2 height='30'>Kepeluan :</td>
						<td colspan=2>$Keperluan</td>
						</tr>						
						<tr>
						<td colspan=2 height='30'>Atasan :</td>
						<td colspan=2>$Atasan</td>
						</tr>						
						<tr>
						<td colspan=4 align='center' height='70' ><h4>Keterangan</h4></td>
						</tr>					
						<tr>
						<td colspan=2 height='30'>Telah  :</td>
						<td colspan=2>$KetApproval</td>
						</tr>						
						<tr>
						<td colspan=2 height='30'>Oleh :</td>
						<td colspan=2>$Approval</td>
						</tr>						
						<tr>
						<td colspan=2 height='30'>Pada tanggal :</td>
						<td colspan=2>$TglKet</td>
						</tr>
						</table>
	";
    $pdf->WriteHTML($strContent);
    $pdf->Output('report.pdf');
    echo "Click <a href='report.pdf'>here</a> To Open";
    ?>  